package com.shenxuchen.crm.mapper;

import com.shenxuchen.crm.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("select * from tbl_user where loginAct=#{username} and loginPwd=#{password}")
    User login(@Param("username") String username, @Param("password") String password);

    @Select("select * from tbl_user where id=#{id}")
    User getById(String id);

    @Update("update tbl_user set loginPwd=#{newPwd} where id=#{id}")
    void changePwd(@Param("id") String id, @Param("newPwd") String newPwd);

    @Insert("insert into tbl_user values(" +
            "#{id}," +
            "#{deptId}," +
            "#{loginAct}," +
            "#{name}," +
            "#{loginPwd}," +
            "#{email}," +
            "#{expireTime}," +
            "#{lockStatus}," +
            "#{allowIps}," +
            "#{createBy}," +
            "#{createTime}," +
            "#{editBy}," +
            "#{editTime})")
    void save(User user);

    @Select("select concat(loginAct, '|', name) from tbl_user")
    List<String> getOwners();
}
